Integrand size = 16, antiderivative size = 68 \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=-\frac {a^2 \text {arctanh}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {b \cos (x)}{a^2+b^2}-\frac {a \sin (x)}{a^2+b^2} \]
[Out]
Time = 0.11 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3178, 3153, 212, 2718} \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=-\frac {a^2 \text {arctanh}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {a \sin (x)}{a^2+b^2}-\frac {b \cos (x)}{a^2+b^2} \]
[In]
[Out]
Rule 212
Rule 2718
Rule 3153
Rule 3178
Rubi steps \begin{align*} \text {integral}& = -\frac {a \sin (x)}{a^2+b^2}+\frac {a^2 \int \frac {1}{a \cos (x)+b \sin (x)} \, dx}{a^2+b^2}+\frac {b \int \sin (x) \, dx}{a^2+b^2} \\ & = -\frac {b \cos (x)}{a^2+b^2}-\frac {a \sin (x)}{a^2+b^2}-\frac {a^2 \text {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,b \cos (x)-a \sin (x)\right )}{a^2+b^2} \\ & = -\frac {a^2 \text {arctanh}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {b \cos (x)}{a^2+b^2}-\frac {a \sin (x)}{a^2+b^2} \\ \end{align*}
Time = 0.25 (sec) , antiderivative size = 62, normalized size of antiderivative = 0.91 \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=\frac {2 a^2 \text {arctanh}\left (\frac {-b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {b \cos (x)+a \sin (x)}{a^2+b^2} \]
[In]
[Out]
Time = 0.37 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.24
method | result | size |
default | \(\frac {8 a^{2} \operatorname {arctanh}\left (\frac {2 a \tan \left (\frac {x}{2}\right )-2 b}{2 \sqrt {a^{2}+b^{2}}}\right )}{\left (4 a^{2}+4 b^{2}\right ) \sqrt {a^{2}+b^{2}}}+\frac {-2 a \tan \left (\frac {x}{2}\right )-2 b}{\left (a^{2}+b^{2}\right ) \left (1+\tan \left (\frac {x}{2}\right )^{2}\right )}\) | \(84\) |
risch | \(\frac {i {\mathrm e}^{i x}}{-2 i b +2 a}-\frac {i {\mathrm e}^{-i x}}{2 \left (i b +a \right )}-\frac {a^{2} \ln \left ({\mathrm e}^{i x}-\frac {i a^{3}+i a \,b^{2}-a^{2} b -b^{3}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}+\frac {a^{2} \ln \left ({\mathrm e}^{i x}+\frac {i a^{3}+i a \,b^{2}-a^{2} b -b^{3}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\) | \(146\) |
[In]
[Out]
Leaf count of result is larger than twice the leaf count of optimal. 144 vs. \(2 (64) = 128\).
Time = 0.27 (sec) , antiderivative size = 144, normalized size of antiderivative = 2.12 \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=\frac {\sqrt {a^{2} + b^{2}} a^{2} \log \left (-\frac {2 \, a b \cos \left (x\right ) \sin \left (x\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a^{2} - b^{2} + 2 \, \sqrt {a^{2} + b^{2}} {\left (b \cos \left (x\right ) - a \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + b^{2}}\right ) - 2 \, {\left (a^{2} b + b^{3}\right )} \cos \left (x\right ) - 2 \, {\left (a^{3} + a b^{2}\right )} \sin \left (x\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \]
[In]
[Out]
Result contains complex when optimal does not.
Time = 76.32 (sec) , antiderivative size = 706, normalized size of antiderivative = 10.38 \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=\begin {cases} \tilde {\infty } \cos {\left (x \right )} & \text {for}\: a = 0 \wedge b = 0 \\- \frac {\cos {\left (x \right )}}{b} & \text {for}\: a = 0 \\- \frac {\sin ^{2}{\left (x \right )}}{3 i b \sin {\left (x \right )} + 3 b \cos {\left (x \right )}} - \frac {2 i \sin {\left (x \right )} \cos {\left (x \right )}}{3 i b \sin {\left (x \right )} + 3 b \cos {\left (x \right )}} - \frac {2 \cos ^{2}{\left (x \right )}}{3 i b \sin {\left (x \right )} + 3 b \cos {\left (x \right )}} & \text {for}\: a = - i b \\- \frac {\sin ^{2}{\left (x \right )}}{- 3 i b \sin {\left (x \right )} + 3 b \cos {\left (x \right )}} + \frac {2 i \sin {\left (x \right )} \cos {\left (x \right )}}{- 3 i b \sin {\left (x \right )} + 3 b \cos {\left (x \right )}} - \frac {2 \cos ^{2}{\left (x \right )}}{- 3 i b \sin {\left (x \right )} + 3 b \cos {\left (x \right )}} & \text {for}\: a = i b \\- \frac {a^{2} \log {\left (\tan {\left (\frac {x}{2} \right )} - \frac {b}{a} - \frac {\sqrt {a^{2} + b^{2}}}{a} \right )} \tan ^{2}{\left (\frac {x}{2} \right )}}{a^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + a^{2} \sqrt {a^{2} + b^{2}} + b^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + b^{2} \sqrt {a^{2} + b^{2}}} - \frac {a^{2} \log {\left (\tan {\left (\frac {x}{2} \right )} - \frac {b}{a} - \frac {\sqrt {a^{2} + b^{2}}}{a} \right )}}{a^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + a^{2} \sqrt {a^{2} + b^{2}} + b^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + b^{2} \sqrt {a^{2} + b^{2}}} + \frac {a^{2} \log {\left (\tan {\left (\frac {x}{2} \right )} - \frac {b}{a} + \frac {\sqrt {a^{2} + b^{2}}}{a} \right )} \tan ^{2}{\left (\frac {x}{2} \right )}}{a^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + a^{2} \sqrt {a^{2} + b^{2}} + b^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + b^{2} \sqrt {a^{2} + b^{2}}} + \frac {a^{2} \log {\left (\tan {\left (\frac {x}{2} \right )} - \frac {b}{a} + \frac {\sqrt {a^{2} + b^{2}}}{a} \right )}}{a^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + a^{2} \sqrt {a^{2} + b^{2}} + b^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + b^{2} \sqrt {a^{2} + b^{2}}} - \frac {2 a \sqrt {a^{2} + b^{2}} \tan {\left (\frac {x}{2} \right )}}{a^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + a^{2} \sqrt {a^{2} + b^{2}} + b^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + b^{2} \sqrt {a^{2} + b^{2}}} - \frac {2 b \sqrt {a^{2} + b^{2}}}{a^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + a^{2} \sqrt {a^{2} + b^{2}} + b^{2} \sqrt {a^{2} + b^{2}} \tan ^{2}{\left (\frac {x}{2} \right )} + b^{2} \sqrt {a^{2} + b^{2}}} & \text {otherwise} \end {cases} \]
[In]
[Out]
none
Time = 0.31 (sec) , antiderivative size = 106, normalized size of antiderivative = 1.56 \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=-\frac {a^{2} \log \left (\frac {b - \frac {a \sin \left (x\right )}{\cos \left (x\right ) + 1} + \sqrt {a^{2} + b^{2}}}{b - \frac {a \sin \left (x\right )}{\cos \left (x\right ) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (b + \frac {a \sin \left (x\right )}{\cos \left (x\right ) + 1}\right )}}{a^{2} + b^{2} + \frac {{\left (a^{2} + b^{2}\right )} \sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}}} \]
[In]
[Out]
none
Time = 0.31 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.38 \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=-\frac {a^{2} \log \left (\frac {{\left | 2 \, a \tan \left (\frac {1}{2} \, x\right ) - 2 \, b - 2 \, \sqrt {a^{2} + b^{2}} \right |}}{{\left | 2 \, a \tan \left (\frac {1}{2} \, x\right ) - 2 \, b + 2 \, \sqrt {a^{2} + b^{2}} \right |}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (a \tan \left (\frac {1}{2} \, x\right ) + b\right )}}{{\left (a^{2} + b^{2}\right )} {\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )}} \]
[In]
[Out]
Time = 20.94 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.38 \[ \int \frac {\sin ^2(x)}{a \cos (x)+b \sin (x)} \, dx=-\frac {\frac {2\,b}{a^2+b^2}+\frac {2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )}{a^2+b^2}}{{\mathrm {tan}\left (\frac {x}{2}\right )}^2+1}-\frac {2\,a^2\,\mathrm {atanh}\left (\frac {2\,a^2\,b+2\,b^3-2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^2+b^2\right )}{2\,{\left (a^2+b^2\right )}^{3/2}}\right )}{{\left (a^2+b^2\right )}^{3/2}} \]
[In]
[Out]